package file

import (
	"fmt"
	"os"
	"strings"
)

// ReplaceAll replace all of content
func ReplaceAll(fileName, old, new string) {
	bytes, err := os.ReadFile(fileName)
	if err != nil {
		fmt.Println(err)
	}
	newContent := strings.ReplaceAll(string(bytes), old, new)
	f, err := os.OpenFile(fileName, os.O_TRUNC|os.O_WRONLY, os.ModePerm)
	if err != nil {
		fmt.Println(err)
	}
	f.WriteString(newContent)
}
